package externalflame.systemdesign.secondkill.controller;


import externalflame.systemdesign.secondkill.entity.SecKill;
import externalflame.systemdesign.secondkill.service.SecKillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(tags = "秒杀规则")
@RestController
@RequestMapping("secKills")
public class SecKillController {

    @Autowired
    SecKillService secKillService;

    @ApiOperation("查询秒杀活动")
    @GetMapping(value = "/{secKillId}", produces = "application/json")
    public SecKill getDetail(@PathVariable("secKillId") Long secKillId) {
        return secKillService.get(secKillId);
    }

    @ApiOperation("创建秒杀活动")
    @PostMapping(value = "/", produces = "application/json")
    public SecKill add(@RequestBody SecKill seckill) {
        return secKillService.add(seckill);
    }

    @ApiOperation("修改秒杀活动")
    @PutMapping(value = "/", produces = "application/json")
    public SecKill update(@RequestBody SecKill secKill) {
        return secKillService.update(secKill);
    }
}
